package utils

import (
	"github.com/gin-contrib/sessions"
	"github.com/gin-gonic/gin"
)

func GetSession(ctx *gin.Context) (ses sessions.Session, val interface{}) {
	ses = sessions.Default(ctx)
	val = ses.Get(0)
	return
}

func SetSession(ses sessions.Session, val interface{}) {
	ses.Set(0, val)
	if err := ses.Save(); err != nil {
		panic(err)
	}
}

func DelSession(ctx *gin.Context) {
	ses := sessions.Default(ctx)
	ses.Clear()
	if err := ses.Save(); err != nil {
		panic(err)
	}
}
